//
//  ThanTheStormViewController.m
//  Gxj
//
//  Created by 刘伟 on 2017/9/13.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "ThanTheStormViewController.h"
#import "HighqualitycomponentsNBViewController.h"
#import "ExcellentIdeaNBViewController.h"

@interface ThanTheStormViewController ()<SGPageTitleViewDelegate, SGPageContentViewDelegate>
@property (nonatomic, strong) SGPageTitleView *pageTitleView;
@property (nonatomic, strong) SGPageContentView *pageContentView;

@end

@implementation ThanTheStormViewController

- (void)viewWillAppear:(BOOL)animated
{
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"创想风暴";
    //导航条内容颜色
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    self.view.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationController.navigationBar.translucent = YES;
//    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg"]forBarMetrics:UIBarMetricsDefault];
    
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:17]};
    //导航条左边按钮
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"fanhui1"] style:UIBarButtonItemStyleDone target:self action:@selector(clickLeftBarButton)];
    //导航条右边按钮
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"fenlei"] style:UIBarButtonItemStyleDone target:self action:@selector(clickRightButton)];
    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;  // 侧滑返回
    [self showThanTheStorm];
}
//导航条返回按钮响应
- (void)clickLeftBarButton
{
    [self.navigationController popViewControllerAnimated:YES];
}
//导航条右边按钮响应
- (void)clickRightButton
{
    
}

- (void)showThanTheStorm
{
    //优质创想
    HighqualitycomponentsNBViewController *childOne = [[HighqualitycomponentsNBViewController alloc] init];
    //卓越创想
    ExcellentIdeaNBViewController *childTwo = [[ExcellentIdeaNBViewController alloc] init];
    
    
    NSArray *childArr = @[childOne,childTwo];
    /// pageContentView
    CGFloat contentViewHeight = self.view.frame.size.height ;
    self.pageContentView = [[SGPageContentView alloc] initWithFrame:CGRectMake(0, kHeightScale(56), self.view.frame.size.width, contentViewHeight) parentVC:self childVCs:childArr];
    _pageContentView.delegatePageContentView = self;
    // _pageContentView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"bggray"]];
    [self.view addSubview:_pageContentView];
    NSArray *titleArr = @[@"优质创想", @"卓越创想"];
    /// pageTitleView
    self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, kHeightScale(64), self.view.frame.size.width, kHeightScale(36)) delegate:self titleNames:titleArr];
    [self.view addSubview:_pageTitleView];
    _pageTitleView.backgroundColor=[UIColor colorWithRed:(242.0/255) green:(242.0/255) blue:(242.0/255) alpha:1];
    _pageTitleView.layer.borderColor=[UIColor whiteColor].CGColor;
    _pageTitleView.selectedIndex = 0;
    _pageTitleView.titleColorStateNormal = [UIColor lightGrayColor];
    _pageTitleView.titleColorStateSelected = [UIColor blackColor];
    _pageTitleView.indicatorColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"huadongtiao"]];
    _pageTitleView.indicatorLengthStyle = SGIndicatorLengthStyleEqual;
    _pageTitleView.isShowBottomSeparator = NO;
}

- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
    [self.pageContentView setPageCententViewCurrentIndex:selectedIndex];
}

- (void)pageContentView:(SGPageContentView *)pageContentView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
    [self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
